package com.csailing4cloud.csailing.common.core.util;

import com.csailing4cloud.csailing.common.core.constants.CommonConstants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author dyh
 * 响应信息主体
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CsResponse<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String code;

    private String message;

    private transient T result;

    public static <T> CsResponse success(T t){
        return new CsResponse(CommonConstants.SUCCESS,CommonConstants.SUCCESS_MSG,t);
    }

    public static <T> CsResponse success(String code, String message, T t){
        return new CsResponse(code,message,t);
    }

    public static  CsResponse fail(String code, String message){
        return new CsResponse(code,message,null);
    }



}
